package com.course.configs;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Rabbit生产者
 */
@Component
public class RabbitProducer {
    private static Logger log = LoggerFactory.getLogger(RabbitProducer.class);

    @Autowired
    AmqpTemplate amqpTemplate;

    public void sendMessage(String topic, String message){
        log.info("send message:"+message);
        amqpTemplate.convertAndSend(topic, message);

    }
}
